package org.nepu.scr.indexrate.converter.compliancerate.datacompleteness.drillingdevice;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.domain.datacompleteness.vo.drillingdevice.DangerAreaDivision;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class DangerAreaDivisionConverter implements AttributeConverter<DangerAreaDivision, String> {
    @Override
    public String convertToDatabaseColumn(DangerAreaDivision dangerAreaDivision) {
        return JSONUtil.toJsonStr(dangerAreaDivision);
    }

    @Override
    public DangerAreaDivision convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, DangerAreaDivision.class);
    }
}
